package com.wenlin.myproduction.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wenlin.myproduction.R;
import com.wenlin.myproduction.bean.ProductBean;

import me.drakeet.multitype.ItemViewBinder;

public class ProductBinder extends ItemViewBinder<ProductBean, ProductBinder.MyWidgetHolder> {


    @NonNull
    @Override
    protected MyWidgetHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new MyWidgetHolder(inflater.inflate(R.layout.item_widget, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull MyWidgetHolder holder, @NonNull ProductBean item) {
        holder.tv.setText(item.getName());
        holder.itemView.setOnClickListener(item.getClickListener());
    }

    static class MyWidgetHolder extends RecyclerView.ViewHolder {
        private TextView tv;

        public MyWidgetHolder(@NonNull View itemView) {
            super(itemView);
            tv = itemView.findViewById(R.id.tv);
        }
    }
}
